rate 5 or 4 の未読数だけ表示。すごく適当。
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use File::Spec;
use lib File::Spec->catfile( $FindBin::Bin, 'lib' );
use List::Util qw/first/;
use Plagger::Schema::SQLite;
my $schema = Plagger::Schema::SQLite->connect( 'dbi:SQLite:/home/typester/workdir/plagger/plagger.db' );
$schema->storage->on_connect_do( ['PRAGMA synchronous = OFF'] );
$| = 1;
while (1) {
my @rates = $schema->resultset('Feed')->search(
{ 'entries.read' => 0 },
{ join => [qw/entries/],
group_by => [qw/me.rate/],
include_columns => ['count(*)'],
order_by => 'me.rate DESC',
}
)->all;
print 'Plagger(';
for my $rate ( reverse 4 .. 5 ) {
my $data = first { $rate eq $_->rate } @rates;
print $data
&& defined $data->get_column('count(*)')
? $data->get_column('count(*)')
: '0';
print ',' unless $rate == 4;
}
print ") \n";
sleep 60;
}